import type { TableColumn } from '@/components/core/dynamic-table';

export type TableListItem = API.FlowListPageResultItem;
export type TableColumnItem = TableColumn<TableListItem>;

export const baseColumns: TableColumn[] = [
  {
    title: '流程名称',
    align: 'left',
    dataIndex: 'name',
    hideInSearch: true,
  },
];

/**
 * 将对应菜单类型转为字符串字意
 */
const getSexType = (type) => {
  switch (type) {
    case 1:
      return '男';
    case 2:
      return '女';
    default:
      return '-';
  }
};

const roleIdParams = [
  {
    label: '超级管理员',
    value: 1,
  },
  {
    label: '市级消防支队支队长',
    value: 2,
  },
  {
    label: '区县消防大队大队长',
    value: 3,
  },
  {
    label: '区县消防大队法治人员',
    value: 31,
  },
  {
    label: '基层组织管理员',
    value: 4,
  },
  {
    label: '基层执法人员',
    value: 41,
  },
];
export const userColumns: TableColumn[] = [
  {
    title: '关键字',
    align: 'left',
    dataIndex: 'keyword',
    hideInTable: true,
    formItemProps: {
      labelWidth: 55,
      componentProps: () => {
        return {
          placeholder: '可输入账号、姓名搜索',
          disabledLabelWidth: true,
        };
      },
    },
  },
  {
    title: '姓名',
    align: 'left',
    dataIndex: 'userName',
    hideInSearch: true,
  },
  {
    title: '账号',
    align: 'left',
    dataIndex: 'userLogin',
    hideInSearch: true,
  },
  {
    title: '手机号',
    align: 'left',
    dataIndex: 'phone',
    hideInSearch: true,
  },
  {
    title: '性别',
    align: 'left',
    dataIndex: 'sex',
    hideInSearch: true,
    width: 100,
    customRender: ({ record }) => getSexType(record.sex),
  },
  {
    title: '部门机构',
    align: 'left',
    dataIndex: 'deptName',
    hideInSearch: true,
  },
  {
    title: '角色名称',
    align: 'left',
    dataIndex: 'roleId',
    formItemProps: {
      component: 'Select',
      componentProps: {
        options: roleIdParams,
      },
    },
    hideInTable: true,
  },
  {
    title: '角色名称',
    align: 'left',
    dataIndex: 'deptName',
    hideInSearch: true,
  },
];
